package com.erp.service.impl;

import com.erp.bean.Commodity;
import com.erp.dao.CommodityDao;
import com.erp.dao.CommodityTypeDao;
import com.erp.dao.impl.CommodityDaoImpl;
import com.erp.dao.impl.CommodityTypeDaoImpl;
import com.erp.service.CommodityService;
import com.erp.util.db.DataBaseDao;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zch
 * 商品业务逻辑实现类
 */
public class CommodityServiceImpl extends DataBaseDao implements CommodityService {

    CommodityDao commodityDao = new CommodityDaoImpl();

    @Override
    public List<Commodity> findAll() {
        return commodityDao.findAll();
    }

    @Override
    public Commodity findByGId(int gid) {
        return commodityDao.findById(gid);
    }

    @Override
    public Commodity findByGname(String gname) {
        return commodityDao.findByName(gname);
    }

    @Override
    public List<Commodity> find(String columm, String values) {
        return commodityDao.find(columm,values);
    }

    @Override
    public List<Commodity> findByTyid(int tyid) {
        return commodityDao.findByTyid(tyid);
    }

    @Override
    public boolean add(Commodity commodity) {
        return commodityDao.add(commodity)>0 ? true:false;
    }

    @Override
    public boolean update(Commodity commodity) {
        return commodityDao.update(commodity)>0?true:false;
    }
}
